﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DelonixRegiaHMSys.Core.Services;
using DelonixRegiaHMSys.Infrastructure.Data;
using DelonixRegiaHMSys.Core.Models;

namespace DelonixRegiaHMSys.UI.WebForms
{
    public partial class SpecificRoomDetails : System.Web.UI.Page
    {
        string userID;
        protected void Page_Load(object sender, EventArgs e)
        {
            userID = Request.QueryString["UserID"];
            lblRoomNum.Text = Request.QueryString["RoomNum"];
            lblroom.Text = Request.QueryString["RoomNum"];
            lblfloorLevel.Text = Request.QueryString["FloorLevel"];
            lblroomType.Text = Request.QueryString["RoomType"];
            lblbedType.Text = Request.QueryString["BedType"];
            lblsmokingOrNot.Text = Request.QueryString["SmokingOrNot"];
            lblmaxOccupancy.Text = Request.QueryString["MaxOccupancy"];
            lblroomStatus.Text = Request.QueryString["RoomStatus"];
            lblroomRates.Text = Request.QueryString["RoomRates"];
            lblGuestID.Text = Request.QueryString["GuestID"];
            if (lblGuestID.Text == "")
            {
                lblCheckOut.Visible = false;
            }
            else
            {
                var gpservice = new gpServices(new EfGuestParticularQuery());
                GuestParticular gp = gpservice.GetGuestbyID(lblGuestID.Text);
                lblGuestLN.Text = gp.GuestLastName;
                lblGuestFN.Text = gp.GuestFirstName;
                lblHA.Text = gp.HomeAddress;
                lblCN.Text = Convert.ToString(gp.ContactNum);
                lblEA.Text = gp.EmailAddress;
                lblMA.Text = gp.MailAddress;
                var ciservice = new ciServices(new EfCheckInQuery());
                lblCheckinID.Text = ciservice.GetCheckinID(lblGuestID.Text);
                lblPM.Text = ciservice.GetPaymentMode(lblCheckinID.Text);
            }
        }

        protected void lblCheckOut_Click(object sender, EventArgs e)
        {
            string querystring = "RoomNum=" + lblRoomNum.Text + "&RoomRates=" + lblroomRates.Text + "&GuestID=" + lblGuestID.Text + "&GuestLN=" + lblGuestLN.Text + "&GuestFN=" + lblGuestFN.Text + "&CheckinID=" + lblCheckinID.Text + "&PaymentMode=" + lblPM.Text + "&UserID=" + userID;
            Server.Transfer("~/WebForms/COandReportingModule/CheckOutManagement.aspx?" + querystring);
        }

        protected void MainpageButton_Click(object sender, EventArgs e)
        {
            Server.Transfer("~/WebForms/SystemAccountModule/MainPage.aspx?UserID=" + userID);
        }
    }
}